﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class ActionClass_Edit : BasePage
{
    private int id;
    protected void Page_Load(object sender, EventArgs e)
    {
        UserPower.CheckAction((int)FreeHouse.Power.Actions.TActionClass.Edit);
        int.TryParse(Request.QueryString["id"], out id);
        if (!IsPostBack)
            BindData();
    }
    protected void save_Click(object sender, EventArgs e)
    {
        error.Items.Clear();
        FreeHouse.Model.TActionClass model = new FreeHouse.Model.TActionClass();
        model.ClassName = ActionClassName.Text.Trim();
        model.Description = Server.HtmlEncode(Description.Text);
        model.ActionClassID = id;
        if (model.ClassName == "")
            error.Items.Add(new ListItem("填写:ActionClassName"));
        if (error.Items.Count == 0)
        {
            //判断ActionClassName是否存在
            FreeHouse.BLL.TActionClass bll = new FreeHouse.BLL.TActionClass();
            bll.Update(model);
            error.Items.Add(new ListItem("修改成功"));

        }
    }

    protected void BindData()
    {
        FreeHouse.Model.TActionClass model = new FreeHouse.BLL.TActionClass().GetModel(id);
        if (model == null) return;
        ActionClassName.Text = model.ClassName.Trim();
        Description.Text = model.Description.Trim();

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        Response.Redirect("Default.aspx");
    }
}
